Repository navigation
feat(channels): set and read channel icons by name - #171
Conversation
The API stores a channel's icon as a name (icon_name) and ignores the old integer icon: writes to it are dropped and it always reads back 0. Add iconName to Channel, CreateChannelArgs and UpdateChannelArgs, export CHANNEL_ICON_NAMES and ChannelIconName as a hint list (the schemas accept any string, as the backend appends icons over time), and mark the integer icon as deprecated. Also make name optional on UpdateChannelArgs: the endpoint takes a partial update, so changing only the icon or colour no longer needs the current name sent back.
doistbot
left a comment
There was a problem hiding this comment.
This PR adds iconName support to channels end to end — the new CHANNEL_ICON_NAMES/ChannelIconName const-array union, iconName on Channel, CreateChannelArgs and UpdateChannelArgs with null resetting to the default, a deprecated integer icon, and an optional UpdateChannelArgs.name — all proven with tests at the public client interface covering create, partial update, reset, and unlisted icon names. No inline issues were flagged; the change follows the established patterns (schema-permissive unions, transport case conversion, shared fixtures) and no concerns were raised for security or reuse.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (2)
src/clients/channels-client.test.ts:138: This test restates the constant rather than exercising behaviour:
toContain('heart')/toContain('apple')duplicate what the array already says, andtoHaveLength(49)has to be edited every time the backend appends a name (the reason the schema accepts any string in the first place). The only invariant worth keeping is the duplicate check on line 139. Consider dropping the containment/length assertions, or deleting the test and lettingentities.test.tscover schema parsing.src/clients/channels-client.test.ts:131:
expect(CHANNEL_ICON_NAMES).not.toContain('rocket')breaks the day the backend appendsrocket, which is exactly the growth this feature exists to absorb — that PR would then have to touch an unrelated test to get green. Use a name that can never be a real icon (e.g.'icon-from-a-newer-api') so the unlisted-name case keeps testing what it's named for.
Use a name that can never be a real icon for the unlisted-name case, and drop the containment and length checks on CHANNEL_ICON_NAMES, which would need editing each time the backend appends an icon.
Build iconName from CHANNEL_ICON_NAMES in the request and Channel schemas, so an unlisted name fails type-check and ChannelIconName is the plain union. A name a newer API returns that this SDK doesn't list yet reads as null, the default icon, rather than failing the parse, which is how the backend asks clients to show an icon they don't know.
## [6.3.0](v6.2.3...v6.3.0) (2026-12-03) ### Features * **channels:** set and read channel icons by name ([#171](#171)) ([31e2624](31e2624))
|
🎉 This PR is included in version 6.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The Comms API now stores a channel's icon as a name, sent and returned as
icon_name. The old integericonis ignored onchannels/addandchannels/update, and always reads back as0. The SDK only knew abouticon, so callers had no way to set or read a channel's icon, and a write toiconsilently did nothing.This adds
iconNametoChannel,CreateChannelArgsandUpdateChannelArgs.nullresets the icon to the default#.CHANNEL_ICON_NAMESlists the 49 names the backend accepts today, and the schemas buildiconNamefrom it, soChannelIconNameis the plain union and an unlisted name fails type-check. The backend appends icons over time, so a newer server can return a name this SDK doesn't list yet:Channel.iconNamereads one asnull, the default icon, rather than failing the parse, which is how the backend asks clients to show an icon they don't know. Callers that validate input (comms-mcp, for its create-channel and update-channel tools) can reuse the list.The integer
iconis marked@deprecatedon the entity and both arg types. Those types are inferred from the Zod schemas, and tsc drops property comments from inferred declarations, so the tag documents it in the source but won't strike the field through in consumers' editors.UpdateChannelArgs.nameis now optional. The endpoint already takes a partial update, so changing only the icon or colour no longer needs the current name sent back. This only widens the type, so nothing existing breaks.